/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RegistrarEleccion.java
 *
 * Created on 14/11/2010, 01:45:26 AM
 */
package zonasoft.Vistas.Funcionales;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.JFrame;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

import zonasoft.Conceptos.Usuario;
import zonasoft.Manejadores.ManejadorBaseDatos;
import zonasoft.Manejadores.ManejadorUsuario;
import java.awt.ComponentOrientation;
import zonasoft.Vistas.inicioSesion;

/**
 *
 * @author JORGE
 */
public class ModificarUsuario extends javax.swing.JDialog {

    /** Creates new form RegistrarEleccion */
    public ModificarUsuario(JFrame parent) {
        super(parent, true);
         initComponents();
        pack();
        Rectangle parentBounds = parent.getBounds();
        Dimension size = getSize();
        // Center in the parent
        int x = Math.max(0, parentBounds.x + (parentBounds.width - size.width) / 2);
        int y = Math.max(0, parentBounds.y + (parentBounds.height - size.height) / 2);
        setLocation(new Point(x, y));
        botonModificar.setEnabled(false);
        campoFecha.setEditable(false);
        tipoUsuario.setEnabled(true);
        Usuario u=inicioSesion.userActual;
        
        if(!u.tieneElRol("superAdministrador"))
        {
            tipoUsuario.removeItemAt(0);
        }
       

        if(u.tieneElRol("usuario"))
        {
           campoFecha.setEditable(true);
          campoId.setText(String.valueOf(u.getId()));
          campoNombre.setText(u.getLogin_usuario());
          campoFecha.setDate(u.getFecha_registro());
          contraseña.setText(u.getClave_usuario());
          contraseña1.setText(u.getClave_usuario());

          botonConsultar.setEnabled(false);
          tipoUsuario.setEnabled(false);
          campoId.setEditable(false);
          campoNombre.setEditable(true);
          campoFecha.setEditable(true);
          contraseña.setEditable(true);
          contraseña1.setEditable(true);


          tipoUsuario.setSelectedIndex(1);
          botonModificar.setEnabled(true);

        }
       

    }
    Usuario us = null;
//    ManejadorUsuario mu = new ManejadorUsuario();

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXPanelElecciones1 = new org.jdesktop.swingx.JXPanel();
        jLabel11 = new javax.swing.JLabel();
        campoId = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        botonConsultar = new javax.swing.JButton();
        botonModificar = new javax.swing.JButton();
        botonCancelar = new javax.swing.JButton();
        RadioHabilitar = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        contraseña = new javax.swing.JPasswordField();
        jLabel10 = new javax.swing.JLabel();
        contraseña1 = new javax.swing.JPasswordField();
        jLabel12 = new javax.swing.JLabel();
        campoFecha = new org.jdesktop.swingx.JXDatePicker();
        jLabel9 = new javax.swing.JLabel();
        campoNombre = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        tipoUsuario = new javax.swing.JComboBox();
        jXTaskPaneContainer1 = new org.jdesktop.swingx.JXTaskPaneContainer();
        jLabel1 = new javax.swing.JLabel();

        setTitle("");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jXPanelElecciones1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.gray, java.awt.Color.lightGray, java.awt.Color.black, java.awt.Color.darkGray), "Datos Personales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Bright", 2, 18))); // NOI18N

        jLabel11.setFont(new java.awt.Font("Lucida Bright", 0, 12)); // NOI18N
        jLabel11.setText("Identificacion");

        campoId.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoIdActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.gray, java.awt.Color.lightGray, java.awt.Color.gray, java.awt.Color.lightGray));

        botonConsultar.setFont(new java.awt.Font("Lucida Bright", 3, 12));
        botonConsultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/search-icon2.png"))); // NOI18N
        botonConsultar.setText("Consultar");
        botonConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonConsultarActionPerformed(evt);
            }
        });

        botonModificar.setFont(new java.awt.Font("Lucida Bright", 3, 12));
        botonModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/Box-Notes-icon.png"))); // NOI18N
        botonModificar.setText("Modificar");
        botonModificar.setEnabled(false);
        botonModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonModificarActionPerformed(evt);
            }
        });

        botonCancelar.setFont(new java.awt.Font("Lucida Bright", 3, 12));
        botonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/Delete-icon.png"))); // NOI18N
        botonCancelar.setText("Cancelar");
        botonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonCancelarActionPerformed(evt);
            }
        });

        RadioHabilitar.setFont(new java.awt.Font("Lucida Bright", 1, 12)); // NOI18N
        RadioHabilitar.setText("Habilitar Campos");
        RadioHabilitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RadioHabilitarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(botonCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(botonModificar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(botonConsultar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(RadioHabilitar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(RadioHabilitar)
                .addGap(7, 7, 7)
                .addComponent(botonConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botonModificar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(botonCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.lightGray, java.awt.Color.gray, java.awt.Color.lightGray, java.awt.Color.gray));

        jLabel8.setFont(new java.awt.Font("Lucida Bright", 0, 12)); // NOI18N
        jLabel8.setText("Contraseña");

        contraseña.setEditable(false);

        jLabel10.setFont(new java.awt.Font("Lucida Bright", 0, 12)); // NOI18N
        jLabel10.setText("Confirma  Contraseña");

        contraseña1.setEditable(false);

        jLabel12.setFont(new java.awt.Font("Lucida Bright", 0, 12)); // NOI18N
        jLabel12.setText("Fecha de Registro");

        campoFecha.setEditable(false);
        campoFecha.setEnabled(false);

        jLabel9.setFont(new java.awt.Font("Lucida Bright", 0, 12)); // NOI18N
        jLabel9.setText("Nombre de Usuario");

        campoNombre.setEditable(false);

        jLabel13.setFont(new java.awt.Font("Lucida Bright", 0, 12)); // NOI18N
        jLabel13.setText("Tipo de Usuario");

        tipoUsuario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "superAdministrador", "Administrador\t", "usuario" }));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(tipoUsuario, 0, 122, Short.MAX_VALUE)
                        .addGap(26, 26, 26))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(contraseña, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)
                            .addComponent(campoFecha, javax.swing.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(campoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(contraseña1, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(tipoUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(campoFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(campoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(contraseña, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(contraseña1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(46, 46, 46))
        );

        javax.swing.GroupLayout jXPanelElecciones1Layout = new javax.swing.GroupLayout(jXPanelElecciones1);
        jXPanelElecciones1.setLayout(jXPanelElecciones1Layout);
        jXPanelElecciones1Layout.setHorizontalGroup(
            jXPanelElecciones1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanelElecciones1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanelElecciones1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanelElecciones1Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(18, 18, 18)
                        .addComponent(campoId, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45))
        );
        jXPanelElecciones1Layout.setVerticalGroup(
            jXPanelElecciones1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanelElecciones1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanelElecciones1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jXPanelElecciones1Layout.createSequentialGroup()
                        .addGroup(jXPanelElecciones1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(campoId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26)
                        .addComponent(jPanel2, 0, 141, Short.MAX_VALUE)))
                .addGap(28, 28, 28))
        );

        getContentPane().add(jXPanelElecciones1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 64, 802, 260));

        jLabel1.setFont(new java.awt.Font("Vani", 3, 18));
        jLabel1.setText("Modificacion de Datos de los Usuarios del Programa");
        jXTaskPaneContainer1.add(jLabel1);

        getContentPane().add(jXTaskPaneContainer1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 840, 46));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonModificarActionPerformed
        // TODO add your handling code here:
        ManejadorBaseDatos mb = ManejadorBaseDatos.getInstancia();
        if (campoId.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "el campo id Eleccion esta vacio", "error", JOptionPane.WARNING_MESSAGE);
        } else if (campoNombre.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "el campo nombre esta vacio", "error", JOptionPane.WARNING_MESSAGE);
        } else if (contraseña.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, " su contraseña  esta vacio", "error", JOptionPane.WARNING_MESSAGE);
        } else if (contraseña1.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, " su confirmacion de contraseña esta vacio", "error", JOptionPane.WARNING_MESSAGE);
        } else if (contraseña.getText() == null ? contraseña1.getText() != null : !contraseña.getText().equals(contraseña1.getText())) {
            JOptionPane.showMessageDialog(null, " por favor confirme su contraseña", "error", JOptionPane.WARNING_MESSAGE);
        } else {
            try {
                us = new Usuario();
                mb.conectar();
                ManejadorUsuario.conm = mb.getConexion();
                //  ManejadorUsuario.con = mb.getConexion();
                int idNuevoRol = 3;

                int id = Integer.parseInt(campoId.getText());
                us.setId(id);
                us.setLogin_usuario(campoNombre.getText());
//               us.setFecha_registro(campoFecha.getDate());
                us.setClave_usuario(contraseña.getText().toString());
//               us.setFecha_registro(campoFecha.getDate());
                if(tipoUsuario.getItemCount()==3)
                {
                  idNuevoRol=tipoUsuario.getSelectedIndex()+1;
                }
                else
                {
                    idNuevoRol=tipoUsuario.getSelectedIndex()+2;
                }
                
                
                ManejadorUsuario.updateUsuario(us, campoId.getText(),idNuevoRol);

                JOptionPane.showMessageDialog(null, " Usuario modificado exitosamente!", "Informacion", JOptionPane.INFORMATION_MESSAGE);
                limpiar();

            } catch (Exception ex) {
                Logger.getLogger(ModificarUsuario.class.getName()).log(Level.SEVERE, null, ex);
            } // catch
        }  // else
    }//GEN-LAST:event_botonModificarActionPerformed

    private void botonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonCancelarActionPerformed
        // TODO add your handling code here:
        int resp = JOptionPane.showConfirmDialog(this, "Seguro que deseas cerrar la Ventana ", "Warning", JOptionPane.YES_NO_OPTION);
        if (resp == JOptionPane.YES_OPTION) {
            this.dispose();
        }
}//GEN-LAST:event_botonCancelarActionPerformed

    private void campoIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoIdActionPerformed
        // TODO add your handling code here:
        botonConsultarActionPerformed(evt);
    }//GEN-LAST:event_campoIdActionPerformed

    private void botonConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonConsultarActionPerformed
        // TODO add your handling code here:
        ManejadorBaseDatos manejabd = ManejadorBaseDatos.getInstancia();
        try {
            manejabd.conectar();
            //ManejadorSimpatizante.conm=manejabd.getConexion();
            ManejadorUsuario.conm = manejabd.getConexion();
            //firmante f = new firmante();
            Usuario us_ = new Usuario();
            Usuario userSession=inicioSesion.userActual;
            //f = ManejadorSimpatizante.getFirmante(campoId.getText());
            us_ = ManejadorUsuario.getUsuario(campoId.getText());
            int rolActual=ManejadorUsuario.getUsuarioRol(campoId.getText());
//            int rolSession=Integer.parseInt(inicioSesion.userActual.getPermisos().get(0));//este es el rol del usuario en la session
             int rolSession=ManejadorUsuario.getUsuarioRol(String.valueOf(userSession.getId()));
            campoFecha.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
            campoFecha.setDate(us_.getFecha_registro());
            campoNombre.setText(us_.getLogin_usuario());
            contraseña.setText("',SHA1("+"'"+us_.getClave_usuario()+"'"+"),'");
            contraseña1.setText("',SHA1("+"'"+us_.getClave_usuario()+"'"+"),'");
            //            contraseña1.setText(us_.getClave_usuario());
            //"',SHA1("+"'"+u.getClave_usuario()+"'"+"),'"
            int rActual=-1;
            if(rolSession==1)
            {
            if(userSession.getId()!=us_.getId())
            tipoUsuario.setEnabled(true);
            else
                tipoUsuario.setEnabled(false);
            rActual=rolActual-1;//se le resta 1 para que coincida con el orden del combobox
            }
            else
            {
                System.out.println(userSession.getId()!=us_.getId());
            if(userSession.getId()!=us_.getId())
            {
                tipoUsuario.setEnabled(true);
            }
            else
            {   tipoUsuario.setEditable(false);}
            rActual=rolActual-2;
           
            }


            if((!campoNombre.getText().equals("")) && (contraseña.getPassword()!=null) && (contraseña1.getPassword()!=null) && (rolActual!=-1))
            {
                    botonModificar.setEnabled(true);
                    System.out.println("rActual-->"+rActual);
                    tipoUsuario.setSelectedIndex(rActual);
            }

            

        } catch (Exception ex) {
            // Logger.getLogger(ConsultaEleccion.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, " Este Usuario no Existe", "Busqueda sin resultados", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_botonConsultarActionPerformed

    private void RadioHabilitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RadioHabilitarActionPerformed
        // TODO add your handling code here:
          if(campoId.toString() == null){
        JOptionPane.showMessageDialog(null, "No hay campos que modificar","Campos Vacios",JOptionPane.ERROR_MESSAGE);
      }else{
        if (RadioHabilitar.isSelected() == true) {
            campoNombre.setEditable(true);
            contraseña.setEditable(true);
            contraseña1.setEditable(true);
            botonModificar.setEnabled(true);
        } else {
            campoNombre.setEditable(false);
            contraseña.setEditable(false);
            contraseña1.setEditable(false);
            botonModificar.setEnabled(false);
        }
      }
    }//GEN-LAST:event_RadioHabilitarActionPerformed

    private void limpiar() {
//    campoId.setText("");
        campoNombre.setText("");
        contraseña.setText("");
        contraseña1.setText("");



    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton RadioHabilitar;
    private javax.swing.JButton botonCancelar;
    private javax.swing.JButton botonConsultar;
    private javax.swing.JButton botonModificar;
    private org.jdesktop.swingx.JXDatePicker campoFecha;
    private javax.swing.JTextField campoId;
    private javax.swing.JTextField campoNombre;
    private javax.swing.JPasswordField contraseña;
    private javax.swing.JPasswordField contraseña1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private org.jdesktop.swingx.JXPanel jXPanelElecciones1;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer1;
    private javax.swing.JComboBox tipoUsuario;
    // End of variables declaration//GEN-END:variables
}
